package org.ala.tiktools.rpc.kcp.spring;

import org.ala.tiktools.rpc.kcp.config.RpcKcpConfigInfo;
import org.ala.tiktools.rpc.kcp.config.RpcKcpConfigInfoParser;
import org.ala.tiktools.rpc.spring.RpcBeanRegisterPostProcessor;
import org.springframework.core.annotation.AnnotationAttributes;
import org.springframework.core.type.AnnotationMetadata;


/**
 * @author ala
 * @date 2025-04-09 16:55
 */
public class KcpRpcBeanRegisterPostProcessor extends RpcBeanRegisterPostProcessor {
    @Override
    protected void beforeParse() {
        RpcKcpConfigInfoParser parser = new RpcKcpConfigInfoParser();
        RpcKcpConfigInfo.INSTANCE = parser.parseKcp(env);
    }
    
	@Override
	protected String[] pkgsFromAnnotation(AnnotationMetadata metadata) {
		AnnotationAttributes attributes = AnnotationAttributes.fromMap(metadata.getAnnotationAttributes(EnableAlaRpcKcp.class.getName()));
		return attributes.getStringArray("basePackages");
	}
}
